package org.pan.domain.db;

import org.pan.domain.DomainObject;

import javax.persistence.*;
import java.util.List;

/**
 * 登陆用户基本信息
 * Created by fangjinliu on 2015/10/29 0029.
 */
@Entity
public class SystemAccount extends DomainObject{

    private static final long serialVersionUID = 7300920932046603132L;

    @Column(unique = true)
    private String username;

    @Column
    private String password;

    @OneToOne(mappedBy = "systemAccount",cascade = CascadeType.REMOVE)
    private SystemAccountBasicInfo systemAccountBasicInfo;

    @ManyToMany
    @JoinTable(name = "account_role",
            joinColumns = {@JoinColumn(name = "account_id",referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}
    )
    private List<SystemRole> systemRoleList;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public SystemAccountBasicInfo getSystemAccountBasicInfo() {
        return systemAccountBasicInfo;
    }

    public void setSystemAccountBasicInfo(SystemAccountBasicInfo systemAccountBasicInfo) {
        this.systemAccountBasicInfo = systemAccountBasicInfo;
    }

    public List<SystemRole> getSystemRoleList() {
        return systemRoleList;
    }

    public void setSystemRoleList(List<SystemRole> hasRoleList) {
        this.systemRoleList = hasRoleList;
    }

    @Override
    public String toString() {
        return "SystemAccount{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
